package com.sdk.es.sdk.entity.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.util.ArrayList;
import java.util.List;

/**
 * @author limaosheng
 * @create 2024-03-07 9:45
 * @desc
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
@Accessors(chain = true)
public class EsParam {
    /**
     * 属性名
     */
    private String fieldName;
    /**
     * es查询关键字，{@link com.sdk.es.sdk.enums.EsQueryKeyEnum}
     */
    private String esQueryKey;
    /**
     * 参数值列表,根据查询关键字匹配对应的单个参数、列表、范围
     */
    private List<String> paramList;

    public static EsParam of(String fieldName, String esQueryKey) {
        EsParam esParam = new EsParam();
        esParam.setFieldName(fieldName);
        esParam.setEsQueryKey(esQueryKey);
        return esParam;
    }

    public static EsParam of(String fieldName, String esQueryKey,String param) {
        EsParam esParam = new EsParam();
        esParam.setFieldName(fieldName);
        esParam.setEsQueryKey(esQueryKey);
        List<String> paramList = new ArrayList<>();
        paramList.add(param);
        esParam.setParamList(paramList);
        return esParam;
    }

    public static EsParam of(String fieldName, String esQueryKey,String start,String end) {
        EsParam esParam = new EsParam();
        esParam.setFieldName(fieldName);
        esParam.setEsQueryKey(esQueryKey);
        List<String> paramList = new ArrayList<>();
        paramList.add(start);
        paramList.add(end);
        esParam.setParamList(paramList);
        return esParam;
    }

    public static EsParam of(String fieldName, String esQueryKey,List<String> paramList) {
        EsParam esParam = new EsParam();
        esParam.setFieldName(fieldName);
        esParam.setEsQueryKey(esQueryKey);
        esParam.setParamList(paramList);
        return esParam;
    }
}
